package com.jane.gzzb;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

import com.jane.gzzb.R;

public class HomePageLiveActivity extends AppCompatActivity implements View.OnClickListener {
    //申明
    private String mUrl;
    private WebView mWebView;
    private TextView mBack;
    private TextView mName;
    private String mCommentator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home_page_live);
        Intent intent = getIntent();
        mUrl = intent.getStringExtra("url");
        mCommentator = intent.getStringExtra("commentator");
        initView();
        initData();
        initListener();
    }

    private void initListener() {
        mBack.setOnClickListener(this);
    }

    private void initData() {
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.setWebChromeClient(new WebChromeClient());
        mWebView.setWebViewClient(new WebViewClient());
        mWebView.loadUrl(mUrl);
        mName.setText(mCommentator);
    }

    private void initView() {
        mWebView = (WebView) findViewById(R.id.activity_home_page_live_webview);
        mBack = (TextView) findViewById(R.id.activity_home_page_live_return);
        mName = (TextView) findViewById(R.id.activity_home_page_live_commentator);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.activity_home_page_live_return:
                this.finish();
                break;
        }
    }
}
